//写入
#include "comm.h"

using namespace std;

int main()
{
    int pipeFd = open(IPC_PATH,O_WRONLY);
    if(pipeFd < 0)
    {
        cerr<<"Open : " << strerror(errno) <<endl;
        return 1;
    }

#define NUM 1024
    char line[NUM];
    //通信
    while(true)
    {
        printf("请输入你的消息# ");
        fflush(stdout);
        memset(line,0,sizeof(line));
        //从键盘按行为单位读取
        if(fgets(line,sizeof(line),stdin) != nullptr )
        {
            line[strlen(line) - 1] = '\0';
            write(pipeFd,line,strlen(line));
        }
        else
        {
            break;
        }
    }

    close(pipeFd);
    cout<< "客户端退出啦"<<endl;
    return 0;
}